﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Messaging;
using HP.Cachalote.WPF.Shared;
using HP.Cachalote.WPF.ViewModel;

namespace HP.Cachalote.WPF
{
    /// <summary>
    /// Interaction logic for DialogWindow.xaml
    /// </summary>
    public partial class DialogWindow : WindowBase
    {
        public MessageBoxResult Result { get; private set; }

        /// <summary>
        /// Constructor of DialogWindow class. Use it to replace the 
        /// regular MessageBoxShow.
        /// </summary>
        /// <param name="message">The message will be shown to user and wait for the response.</param>
        public DialogWindow(string message)
        {
            InitializeComponent();

            TextBlockMessage.Text = message;
        }

        private void BtnYes_Click(object sender, RoutedEventArgs e)
        {
            ConfirmCompleted(MessageBoxResult.Yes);
        }

        private void BtnNo_Click(object sender, RoutedEventArgs e)
        {
            ConfirmCompleted(MessageBoxResult.No);
        }

        /// <summary>
        /// Confirm with user completed. The result will be accpeted and 
        /// this DialogWindows is closing.
        /// </summary>
        /// <param name="result"></param>
        private void ConfirmCompleted(MessageBoxResult result)
        {
            Result = result;
            Close();
        }
    }
}
